﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MadLibrary.Collections;

namespace MadLibrary.Managing.Items
{
    /// <summary>
    /// Holds and manages items.
    /// </summary>
    public class Items : Collection<Item>
    {
        /// <summary>
        /// Creates new empty item collection.
        /// </summary>
        public Items()
            : base()
        { 
            
        }
        /// <summary>
        /// Creates new item collection with specified default items.
        /// </summary>
        /// <param name="Items">Specifies items which have to be defaultly added into new item collection.</param>
        public Items(params Item[] Items)
            : base(Items)
        {
            
        }
        /// <summary>
        /// Sorts items in current collection by specified property.
        /// </summary>
        /// <param name="sort">Specifies property for sorting.</param>
        public void Sort(ItemsSort sort)
        {
            if (sort == ItemsSort.ID)
                this.data = this.data.OrderBy(i => i.ID).ToArray();
            else if(sort==ItemsSort.Name)
                this.data = this.data.OrderBy(i => i.Name).ToArray();
        }
    }
}
